package com.qf.java2105.huangchuang.hotel.controller.food;

import com.qf.java2105.huangchuang.hotel.entity.ResultVO;
import com.qf.java2105.huangchuang.hotel.factory.BeanFactory;
import com.qf.java2105.huangchuang.hotel.pojo.Food;
import com.qf.java2105.huangchuang.hotel.pojo.FoodType;
import com.qf.java2105.huangchuang.hotel.service.IFoodService;
import com.qf.java2105.huangchuang.hotel.service.IFoodTypeService;
import com.qf.java2105.huangchuang.hotel.service.impl.FoodServiceImpl;
import com.qf.java2105.huangchuang.hotel.service.impl.FoodTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 菜品添加页面菜系查询
 * @author hcvg
 * @version v1.0
 * @date 2021/09/12
 **/
@WebServlet("/food/saveui")
public class FoodSaveUiController extends HttpServlet {
    IFoodTypeService foodTypeService  = (IFoodTypeService) BeanFactory.getBean("foodTypeService");
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        ResultVO<List<FoodType>> resultVO = foodTypeService.findByFoodTypeName(null);
        request.setAttribute("foodtypes", resultVO.getData());
        request.getRequestDispatcher(request.getContextPath() + "/backend/detail/food/food-save.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
